%module AnyWrapperModule

%import "LibDL/Tensor/Tensor.i"

SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)

%include "std_string.i"

%nspace AnyWrapper;
%rename (AnyWrapper) any_wrapper;
%{
#include "./LibDL/ordered_dict/boost_any_wrapper.h"
#include "./LibDL/ordered_dict/ordered_dict.h"
#include "./LibDL/Tensor/Tensor.h"
#include <boost/any.hpp>
%}

%include "./LibDL/ordered_dict/boost_any_wrapper.h"

%ignore operator=;

%template(StdPairTensorBool) std::pair<Tensor, bool>;

%template(TensorContent) any_wrapper::content<Tensor>;
%template(StringContent) any_wrapper::content<std::string>;
%template(StdPairContent) any_wrapper::content<std::pair<Tensor, bool>>;
%template(AnyContent) any_wrapper::content<boost::any>;

%template(IsTensor) any_wrapper::is_type<Tensor>;
%template(IsString) any_wrapper::is_type<std::string>;
%template(IsStdPair) any_wrapper::is_type<std::pair<Tensor, bool>>;
%template(IsAny) any_wrapper::is_type<boost::any>;
//this is proxy for any_wrapper get content include any_wrapper
//for the swig contains the bug, when template contains self
//it will generate the type of aa::aa
%inline %{
Ordered_dict<std::string, any_wrapper> OrderedDictContent(any_wrapper any) noexcept{
    if (utils::can_cast_to<Ordered_dict<std::string, any_wrapper>>(any.get_core()))
        return utils::try_any_cast<Ordered_dict<std::string, any_wrapper>>(any.get_core());
    else
        return Ordered_dict<std::string, any_wrapper>();
}

bool IsOrderedDict(any_wrapper any) noexcept{
    return utils::can_cast_to<Ordered_dict<std::string, any_wrapper>>(any.get_core());
}
%}
